export default {
	namespaced: true,
	// 数据
	state:()=>({
		address: JSON.parse(uni.getStorageSync('address') || '{}')
	}),
	
	// 方法
	mutations :{
		updateAddress(state,address){
			state.address = address
			this.commit('m_user/saveAddressToStorage')
		},
		// 存储购物车数据到本地
		saveAddressToStorage(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		}
	},
	
	// 数据包装
	getters:{
		addresslast(state){
			// 判断省份是否存在
			if(!state.address.provinceName) return ''
			return state.address.provinceName + state.address.cityName + state.address.countyName + state.address.detailInfo
		}
	}
}